﻿<div ng-controller="Finance_AccountListC">

    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">客户账户流水 -- {{$stateParams.name}}</h1>
    </div>
    <div class="wrapper-md" style="text-align: center;">
        <span class="input-group-btn" >
            <button type="button" class="btn btn-default" style="float: left;" ng-click="goorderList()">返回列表</button> 
        </span>
        <div class="panel panel-default">

            <div class="panel-heading">
                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12" style="float: right">

                </div>
            </div>
            <div class="table-responsive">
                <table id="example1" class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th style="text-align: center;">户头</th>
                        <th style="text-align: center;">变动前</th>
                        <th style="text-align: center;">金额</th>
                        <th style="text-align: center;">变动后</th>
                        <th style="text-align: center;">处理人</th>
                        <th style="text-align: center;">信息</th>
                        <th style="text-align: center; display:none;">外部编号</th>
                        <th style="text-align: center;">备注</th>
                        <th style="text-align: center;">创建时间</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="item in pageData.Data  | orderBy:['-CreateTime']">
                            <td style="width: 15%">{{item.Account.Name}}</td>
                            <td style="width: 10%">{{item.BeforeAmount | number:2}}</td>
                            <td style="width: 10%">{{item.Money | number:2}}</td>
                            <td style="width: 10%">{{item.AfterAmount | number:2}}</td>
                            <td style="width: 10%">{{item.Handler.Name}}</td>
                            <td style="width: 10%">{{item.SourceInfo}}</td>
                            <td style="width: 10%;display:none;">{{item.SourceTag}}</td>
                            <td style="width: 15%">{{item.Remark}}</td>
                            <td style="width: 10%">{{item.CreateTime}}</td>
                        </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td></td>
                        <td>收入总计：</td>
                        <td>{{incomesum | number:2}}</td>
                        <td></td>
                        <td>支出总计：</td>
                        <td>{{expendituresum | number:2}}</td>
                    </tr>
                    </tfoot>
                </table>
                <!--<div class="panel-heading" ng-include="'/htm/tpl/Supplier/Paging.html'">-->
                <!--</div>-->

            </div>

        </div>
    </div>
</div>
<script>
    angular.module('app')//非标优惠
    .controller("Finance_AccountListC", function ($scope, $state, $http,$stateParams) {
        $scope.pageData = {};
        $scope.pageData.Page = 1;
        $scope.pageData.Rows = $scope.defPageRows;
        $scope.incomesum = 0;
        $scope.expendituresum = 0;
        $scope.getData = function (p, r) {
            if (p) {
                p = p < 1 ? 1 : p;
            } else p = 1;
            if (r) {
            } else r = $scope.defPageRows;
            $http({
                url: "/api/Finance/List",
                method: "GET", 
                params: { customerId: $stateParams.id,accountId: $stateParams.id, page: 1, rows: 9999 }
            })
            .then(function (res) {
                $scope.pageData = res.data;
                console.log($scope.pageData.Data);
                for (var i=0;i<$scope.pageData.Data.length;i++)
                {
                    if($scope.pageData.Data[i].Money <= 0){
                        $scope.expendituresum += $scope.pageData.Data[i].Money
                    }else{
                        $scope.incomesum += $scope.pageData.Data[i].Money
                    }
                }
            })
            .then(function (error) {
                if (error) {
                    alert("数据获取失败");
                }
            });
        };
        $scope.goorderList = function(){
                history.go(-1)
            };
        $scope.getData(1, $scope.pageData.Rows);
        })
</script>
